﻿<Window x:Class="Waf.MusicManager.Presentation.Views.ShellWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:Waf.MusicManager.Presentation.Properties"
        xmlns:ctrl="clr-namespace:Waf.MusicManager.Presentation.Controls"
        xmlns:dd="clr-namespace:Waf.MusicManager.Presentation.DesignData"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
        mc:Ignorable="d" Height="500" Width="800" Icon="{StaticResource MusicManagerIcon}"
        d:DataContext="{d:DesignInstance dd:SampleShellViewModel, IsDesignTimeCreatable=True}">

    <Window.Title>
        <MultiBinding Converter="{StaticResource WindowTitleConverter}">
            <Binding Path="PlayerService.PlayingMusicFile.Metadata.Artists" Converter="{StaticResource StringListToStringConverter}" ConverterParameter="ListSeparator"/>
            <Binding Path="PlayerService.PlayingMusicFile.Metadata.Title"/>
            <Binding Path="Title"/>
        </MultiBinding>
    </Window.Title>

    <Window.TaskbarItemInfo>
        <TaskbarItemInfo>
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo Command="{Binding PlayerService.PreviousCommand}" ImageSource="{StaticResource PreviousButtonImage}"/>
                <ThumbButtonInfo x:Name="playPauseButton" Command="{Binding PlayerService.PlayPauseCommand}"/>
                <ThumbButtonInfo Command="{Binding PlayerService.NextCommand}" ImageSource="{StaticResource NextButtonImage}"/>
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    
    <Window.InputBindings>
        <KeyBinding Command="{Binding GarbageCollectorCommand}" Key="G" Modifiers="Control+Shift"/>
    </Window.InputBindings>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="250"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="2"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <Border Grid.ColumnSpan="3" Grid.Row="0" BorderBrush="Transparent" BorderThickness="0,0,0,1" Background="Red">
            <Border.Style>
                <Style TargetType="Border">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Errors.Count}" Value="0">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock Foreground="White" Padding="5,4" TextTrimming="CharacterEllipsis">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource ErrorMessagesConverter}">
                            <Binding Path="Errors"/>
                            <Binding Path="Errors.Count"/>
                        </MultiBinding>
                    </TextBlock.Text>
                    <TextBlock.ToolTip>
                        <ctrl:SuperToolTip Title="{x:Static p:Resources.InternalErrorDescription}" Description="{Binding LastError.Item1.Message}"/>
                    </TextBlock.ToolTip>
                </TextBlock>

                <Button Command="{Binding CloseErrorCommand}" Style="{StaticResource CloseButtonStyle}" Grid.Column="1"/>
            </Grid>
        </Border>
        
        <ContentControl Content="{Binding ShellService.ContentView}" Grid.Column="0" Grid.Row="1" Focusable="False"/>
        
        <GridSplitter Grid.Column="1" Grid.Row="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Width="6" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>

        <DockPanel Grid.Column="2" Grid.Row="1">
            <Grid DockPanel.Dock="Top" Margin="0,0,0,1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <ToggleButton Content="{x:Static p:Resources.Details}" IsChecked="{Binding IsMusicPropertiesViewVisible}" Grid.Column="0"
                              Height="23" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" Margin="0,0,1,0"/>
                <ToggleButton Content="{x:Static p:Resources.Playlist}" IsChecked="{Binding IsPlaylistViewVisible}" Grid.Column="1"
                              Height="23" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" Margin="0,0,1,0"/>
                <ToggleButton Content="{x:Static p:Resources.Convert}" IsChecked="{Binding IsTranscodingListViewVisible}" Grid.Column="2"
                              Height="23" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
            </Grid>
            
            <ContentControl Content="{Binding DetailsView}" Focusable="False"/>    
        </DockPanel>
        
        <ContentControl Content="{Binding ShellService.PlayerView}" Focusable="False" Grid.ColumnSpan="3" Grid.Row="3"/>
    </Grid>
</Window>
